home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 May / CMCD0504.ISO / Software / Freeware / Programare / gdiplusdelphi / demos / Using Graphics Containers / Nested Graphics Containers / Transformations in Nested Containers / GDITEST69.dpr
Encoding:
Text File  |  2003-10-15  |  2.5 KB  |  99 lines

  1. program GDITEST69;
  2.  
  3. uses
  4.   Windows,
  5.   Messages,
  6.   SysUtils,
  7.   GDIPAPI,
  8.   GDIPOBJ;
  9.  
  10. Procedure OnPaint(DC: HDC);
  11. var
  12.   graphics : TGPGraphics;
  13.   Pen: TGPPen;
  14.   GContainer: GraphicsContainer;
  15. begin
  16.   graphics := TGPGraphics.Create(DC);
  17.  
  18.   Pen := TGPPen.Create(MakeColor(255, 255, 0, 0));
  19.  
  20.   graphics.TranslateTransform(100.0, 80.0);
  21.  
  22.   GContainer := graphics.BeginContainer;
  23.      graphics.RotateTransform(30.0);
  24.      graphics.DrawRectangle(pen, -60, -30, 120, 60);
  25.   graphics.EndContainer(GContainer);
  26.  
  27.   graphics.DrawRectangle(pen, -60, -30, 120, 60);
  28.  
  29.   Pen.Free;
  30.   graphics.Free;
  31. end;
  32.  
  33.  
  34. function WndProc(Wnd : HWND; message : UINT; wParam : Integer; lParam: Integer) : Integer; stdcall;
  35. var
  36.   Handle: HDC;
  37.   ps: PAINTSTRUCT;
  38. begin
  39.   case message of
  40.     WM_PAINT:
  41.       begin
  42.         Handle := BeginPaint(Wnd, ps);
  43.         OnPaint(Handle);
  44.         EndPaint(Wnd, ps);
  45.         result := 0;
  46.       end;
  47.  
  48.     WM_DESTROY:
  49.       begin
  50.         PostQuitMessage(0);
  51.         result := 0;
  52.       end;
  53.  
  54.    else
  55.       result := DefWindowProc(Wnd, message, wParam, lParam);
  56.    end;
  57. end;
  58.  
  59. var
  60.   hWnd     : THandle;
  61.   Msg      : TMsg;
  62.   wndClass : TWndClass;
  63. begin
  64.    wndClass.style          := CS_HREDRAW or CS_VREDRAW;
  65.    wndClass.lpfnWndProc    := @WndProc;
  66.    wndClass.cbClsExtra     := 0;
  67.    wndClass.cbWndExtra     := 0;
  68.    wndClass.hInstance      := hInstance;
  69.    wndClass.hIcon          := LoadIcon(0, IDI_APPLICATION);
  70.    wndClass.hCursor        := LoadCursor(0, IDC_ARROW);
  71.    wndClass.hbrBackground  := HBRUSH(GetStockObject(WHITE_BRUSH));
  72.    wndClass.lpszMenuName   := nil;
  73.    wndClass.lpszClassName  := 'GettingStarted';
  74.  
  75.    RegisterClass(wndClass);
  76.  
  77.    hWnd := CreateWindow(
  78.       'GettingStarted',       // window class name
  79.       'Transformations in Nested Containers',      // window caption
  80.       WS_OVERLAPPEDWINDOW,    // window style
  81.       Integer(CW_USEDEFAULT), // initial x position
  82.       Integer(CW_USEDEFAULT), // initial y position
  83.       Integer(CW_USEDEFAULT), // initial x size
  84.       Integer(CW_USEDEFAULT), // initial y size
  85.       0,                      // parent window handle
  86.       0,                      // window menu handle
  87.       hInstance,              // program instance handle
  88.       nil);                   // creation parameters
  89.  
  90.    ShowWindow(hWnd, SW_SHOW);
  91.    UpdateWindow(hWnd);
  92.  
  93.    while(GetMessage(msg, 0, 0, 0)) do
  94.    begin
  95.       TranslateMessage(msg);
  96.       DispatchMessage(msg);
  97.    end;
  98. end.
  99.